package WaiBao;

import java.util.Arrays;

public class LiuJiaYu {
    public static void main(String[] args) {
        String[] name = {"印子月(班长)", "程响(团支书)", "小李(学习委员)", "李玉刚(体育委员)", "张杰", "王丽", "王悦", "王涛", "谢娜", "立志", "董成鹏", "倪大红",
                "华晨宇", "张劲松", "曲小刚", "张碧晨", "杨迪", "鹿晗", "黄凯", "黄志愿", "吉鲁", "姜子牙", "张建辉", "黄勇", "李志康", "汪峰", "乾隆", "朱元璋",
                "那英", "刘佳宇(学生)"};//考生本人:刘佳宇(学生)
        int[] age = {22,21, 20, 19, 18, 21, 21, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 21, 18, 22, 21, 20, 19};//考生年龄：19岁

        double[] jieguo1 = {87, 92, 84, 91, 79, 69, 78, 89, 80, 81, 91, 85, 85, 89, 65, 68, 99, 69, 96, 88, 92, 91, 95, 65, 75, 74, 95, 78, 87, 95};
        double[] jieguo2 = {77, 81, 79, 76, 75, 77, 79, 69, 90, 70, 90, 77, 66, 95, 65, 75, 76, 90, 68, 98, 72, 71, 95, 86, 75, 88, 83, 65, 84, 96};
        double[] jieguo3 = {64, 77, 84, 85, 77, 66, 61, 69, 80, 80, 93, 87, 84, 65, 65, 68, 69, 76, 96, 93, 92, 81, 65, 95, 76, 84, 78, 74, 82, 94};


        double keshi1;//代表每个学生的总分
        double keshi2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            keshi1 = jieguo1[i] + jieguo2[i] + jieguo3[i];
//            keshi2 = (keshi1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + keshi1);
//            System.out.println(name[i] + "的平均分为:" + keshi2);
//        }


        double manman1 = 0, manman2 = 0;
        double[] lege = new double[30];
//        for (int i = 0; i < 30; i++) {
//            manman1 = jieguo1[i] + jieguo2[i] +jieguo3[i];
//            manman2 = (manman1 * 1.0) / 3;
//            lege[i] =manman2;
//        }
//
//        for (int i = 0; i < lege.length - 1; i++) {
//            for (int j = 0; j < lege.length - i - 1; j++) {
//                if (lege[j] < lege[j + 1]) {
//                    double tep =lege[j];
//                    lege[j] = lege[j + 1];
//                    lege[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(lege[i]);
//        }


        double keyi1 = 0, keyi2 = 0, keyi3 = 0;//计算每门课的平均分
        double fang1 = 0, fang2 = 0, fang3 = 0;//计算每门课标准差
        double buyong1 = 0,buyong2 = 0, buyong3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <jieguo1.length; i++) {
            he += jieguo1[i];
        }
        keyi1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + keyi1);
        double Sum = 0;
        for (int i = 0; i < jieguo2.length; i++) {
            Sum += jieguo2[i];
        }
        keyi2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + keyi2);
        double sum = 0;
        for (int i = 0; i < jieguo3.length; i++) {
            sum += jieguo3[i];
        }
        keyi3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" +keyi3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < jieguo1.length; i++) {
            c1 += (jieguo1[i] - keyi1) * (jieguo1[i] - keyi1);
        }
        fang1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + fang1);
        for (int i = 0; i < jieguo2.length; i++) {
            c2 += (jieguo2[i] - keyi2) * (jieguo2[i] - keyi2);
        }
        fang2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + fang2);

        for (int i = 0; i < jieguo3.length; i++) {
            c3 += (jieguo3[i] - keyi3) * (jieguo3[i] - keyi3);
        }
        fang3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + fang3);
////
//
//
        Arrays.sort(jieguo1);
        Arrays.sort(jieguo2);
        Arrays.sort(jieguo3);
        buyong1 = (jieguo1[14] + jieguo2[15]) * 1.0 / 2;
        buyong2 = (jieguo2[14] + jieguo2[15]) * 1.0 / 2;
        buyong3 = (jieguo3[14] + jieguo3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + buyong1);
        System.out.println("物理化学的中位数为:" + buyong2);
        System.out.println("电子与电工技术的中位数为:" + buyong3);

    }
}
